#include <climits>
#include <iostream>
using namespace std;
 
int main()
{
    string str;
    int n = 0;
    cin >> str >> n;
    int sz = str.size();
    int cnt = 0; // 统计C和G数量
 
    int begin = 0, cur = 0, maxCnt = INT_MIN;
    while(cur < sz - n)
    {
        cnt = 0;
        for(int i = cur; i < cur + n; ++i)
        {
            if(str[i] == 'C' || str[i] == 'G')
                ++cnt;
        }
        if(cnt > maxCnt)
        {
            begin = cur;
            maxCnt = cnt;
        }
        ++cur;
    }
    string res(str.begin() + begin, str.begin() + begin + n);
    cout << res << endl;
    return 0;
}